package com.zhang.family_doctor.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import com.zhang.family_doctor.dto.ServicesDto;
import com.zhang.family_doctor.entity.R;
import com.zhang.family_doctor.entity.Services;
import com.zhang.family_doctor.service.ServicesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 服务项目管理
 */
@RestController
@RequestMapping("/services")
@Slf4j
@Api(tags = "服务项目管理")
public class ServicesController {

    @Autowired
    private ServicesService servicesService;

    @ApiOperation("新增服务项目")
    @PostMapping("/save")
    public R<String> save(@RequestBody Services services){
        log.info("新增服务项目：{}",services);
        return servicesService.save(services);
    }

    @ApiOperation("修改服务项目")
    @PostMapping("/update")
    public R<String> update(@RequestBody Services services){
        log.info("修改服务项目：{}",services);
        return servicesService.update(services);
    }

    @ApiOperation("分页查询服务项目")
    @GetMapping("/getList")
    public R<PageInfo<Services>> getList(ServicesDto servicesDto){
        log.info("分页查询服务项目：{}",servicesDto);
        return servicesService.getList(servicesDto);
    }

    @ApiOperation("根据id删除服务项目")
    @DeleteMapping("/delete")
    public R<String> delete(Integer id){
        log.info("根据id删除服务项目：{}",id);
        return servicesService.delete(id);
    }
}
